<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>知识库列表页</title>
    <include file="Public:easyui_res" />
    <style>
        table img{
            cursor:pointer;
        }
    </style>
</head>
<body>
<div id="tb" style="padding:5px;height:auto;">
    <div style="margin: 10px 0 10px 10px" >
        <!-- form表单 指定id和name之后会自动带到服务器 -->
        <form name="searchform" method="get" action="" id ="searchform" style="height:20px;margin-bottom: 20px">
            <label for="forum_id">栏目分类：</label>
            <select class="easyui-combobox" id ="forum_id" name="forum_id" style="width:140px;height:32px;">
                <option value="0">全部</option>
                <foreach name="forum_list" item="vo">
                    <option value="{$vo.forum_id_lm}">{$vo.forum_name_lm}</option>
                </foreach>
            </select>
            <label for="author">文章来源：</label>
            <select class="easyui-combobox" id ="author" name="author" style="width:140px;height:32px;">
                <option value="">不限</option>
                <option value="贵健康">贵健康</option>
                <option value="39健康网">39健康网</option>
            </select>
            <label for="is_good">精选：</label>
            <select class="easyui-combobox" id ="is_good" name="is_good" style="width:140px;height:32px;">
                <option value="0">不限</option>
                <option value="1">非精选</option>
                <option value="2">精选</option>
            </select>
            <label for="article_title">关键字：</label>
            <input class="easyui-textbox" id="article_title" name="article_title" data-options="prompt:'按文章标题查询'" style="width:140px;height:32px"/>

            <a href="javascript:void(0);" id="submit_search" class="easyui-linkbutton" iconCls="icon-search"  style="width:60px;height:32px">查询</a>
            <a href="__URL__/edit" class="easyui-linkbutton" iconCls="icon-add"  style="height:32px;float: right;margin-right: 60px">添加</a>
            <!--<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-save" onclick="save_order()"  style="height:32px;float: right;margin-right: 60px">保存</a>-->
        </form>
    </div>
</div>
<table id="dg"  style="width:100%; "  title="查询结果"
       data-options="rownumbers:false,
			singleSelect:true,
			pagination:true,
			ctrlSelect:true,
			fitColumns:true,
			loadMsg:'正在加载,请等待....',
			url:'__URL__/getList',
			method:'post',
			toolbar:'#tb',
			">
    <thead>
    <tr>
        <!--<volist name="table_title" id="vo"  >
            <th data-options="field:'{$key}',align:'center',width:'10px'">{$vo}</th>
        </volist>-->
        <th data-options="field:'article_title',align:'center',width:'10px'">文章标题</th>
        <th data-options="field:'title_pic',align:'center',width:'10px'">标题图片</th>
        <th data-options="field:'forum_name_lm',align:'center',width:'10px'">所属栏目</th>
        <th data-options="field:'author',align:'center',width:'10px'">文章来源</th>
        <th data-options="field:'pub_date',align:'center',width:'10px'">发布时间</th>
        <th data-options="field:'actually_read_count',align:'center',width:'10px'">访问量</th>
        <th data-options="field:'action',align:'center',width:'20px'">操作提示</th>
    </tr>
    </thead>
</table>
<script type="text/javascript">
    function view_pic(url){
        var data = "<img src='"+url+"' id='pic' height='300px' />";
        $.messager.alert('查看图片',"",'info');
        $(".messager-window").css("width","");
        $(".messager-body").css("width","");
        $(".window-header").css("width","");
        $(".messager-window").css("left","100px");
        $(".messager-window").css("top","40px");
        $(".window-shadow").css("display","none");
        $(".messager-body").html(data);
    }
    function go_top(id,type){
        $.ajax( {
            url: '__URL__/goTop',
            type: 'post',
            data: {'article_id':id,'type':type},
            cache:false,
            dataType:'json',
            success: function (data){
                if(data == 0){
                    $("#submit_search").click();
                }else{
                    alert('置顶失败！');
                }
            },
            error: function (data, status, e){
                alert(e);
            }
        });
    }
    function go_send(id){
        $.messager.confirm('提示', '确定要推送吗?', function(r){
            if(r){
                $.ajax( {
                    url: '__URL__/articleSend',
                    type: 'post',
                    data: {'article_id':id},
                    cache:false,
                    dataType:'json',
                    success: function (data){
                        if(data >0 ){ //影响行大于0则成功
                            m_info("推送成功");
                            $("#submit_search").click();
                        }else{
                            m_erro("推送失败");
                        }
                    },
                    error: function (data, status, e){
                        m_erro(e);
                    }
                });
            }
        });
    }
    function set_essence(id,state){
        $.ajax( {
            url: '__URL__/setEssence',
            type: 'post',
            data: {'article_id':id,'type':state},
            cache:false,
            dataType:'json',
            success: function (data){
                if(data == 0){
                    $("#submit_search").click();
                }else{
                    alert('失败！');
                }
            },
            error: function (data, status, e){
                alert(e);
            }
        });
    }
    function article_delete(id){
        $.messager.confirm('提示', '确定要删除吗?', function(r){
            if(r){
                $.ajax( {
                    url: '__URL__/delete',
                    type: 'post',
                    data: {'article_id':id},
                    cache:false,
                    dataType:'json',
                    success: function (data){
                        if(data >0 ){ //影响行大于0则成功
                            m_info("删除成功");
                            $("#submit_search").click();
                        }else{
                            m_erro("删除失败");
                        }
                    },
                    error: function (data, status, e){
                        m_erro(e);
                    }
                });
            }
        });
    }
    function save_order(){
        var data = new Array();
        $("table").find('input').each(function(){
            if($(this).attr('rel') != undefined) {
                var d = {'article_id': $(this).attr('rel'), 'lm_top': $(this).val()};
                data.push(d);
            }
        });
        console.info(data);
        $.ajax( {
            url: '__URL__/saveOrder',
            type: 'post',
            data: {'data':data},
            cache:false,
            dataType:'json',
            success: function (data){
                if(data >0 ){ //影响行大于0则成功
                    m_info("更新成功");
                    $("#submit_search").click();
                }else{
                    m_erro("更新失败");
                }
            },
            error: function (data, status, e){
                m_erro(e);
            }
        });
    }
</script>
</body>
</html>